

window.onload = function () {
    
}
    slideIndex = 1;
    //推荐大图的左右切换
    function showSlides(n) {
        let slides = document.getElementsByClassName("banner-item");
        let dots = document.getElementsByClassName("dot");
        //获取上边区域，设置背景
        let recommendTopBg = document.getElementById("recommendTop");
        
        if (n > slides.length) {slideIndex = 1}
        if (n < 1) {slideIndex = slides.length}
        //获取当前大图图片的地址
        let imgUrl = document.getElementsByClassName("img")[slideIndex-1];

        

        for (let i = 0; i < slides.length; i++) {
            slides[i].style.display = "none";
        }
        for (let i = 0; i < dots.length; i++) {
            dots[i].className = dots[i].className.replace("active", "");
        }

        slides[slideIndex-1].style.display = "block";
        dots[slideIndex-1].className += " active";
        recommendTopBg.style.setProperty('--bg-image',`url(${imgUrl.src})`);
        
    }
    //推荐大图的左右切换
    function moveSlide(n) {
        showSlides(slideIndex += n);
    }

    // 点击小点点时切换幻灯片
    function currentSlide(n) {
        showSlides(slideIndex = n);
    }
    
    // 初始化时显示第一张图片
    showSlides(slideIndex);